function banner() {
  const banner_ul = document.getElementsByClassName("banner")[0];
  let banner_lis = banner_ul.getElementsByTagName("li");
  const leftbtn = document.getElementById('left');
  const rightbtn = document.getElementById('right');
  // console.log(leftbtn);
  let banner_timer = null;
  let banner_index = 0;
  function lunbo(ls) {
    for(let i=0;i<ls.length;i++){
        ls[banner_index].style.display = 'none';
    }
    if (banner_index >= ls.length - 1) {
      banner_index = 0;
    } else {
      banner_index++;
    }
    ls[banner_index].style.display = "list-item";
    // console.log("轮播"+index);
  }
  banner_timer = setInterval(function(){
    lunbo(banner_lis)
  }, 2000);

  //鼠标悬停时，停止轮播
  banner_ul.onmouseover = function(){
    clearInterval(banner_timer)
  }


  //鼠标移走,将继续轮播
  banner_ul.onmouseout = function(){
    banner_timer = setInterval(function(){
        lunbo(banner_lis)
    },2000)
  }
  
  //点击左边按钮切换上一张图片
leftbtn.onclick = function() {
    for(let i=0;i<banner_lis.length;i++){
        banner_lis[banner_index].style.display = 'none';
    }
    if (banner_index < banner_lis.length&&banner_index>0) {
      banner_index--;
    } else {
      banner_index = banner_lis.length-1;
    }
    banner_lis[banner_index].style.display = "list-item";
    return false;
  }

  //点击右边按钮切换下一张图片
  rightbtn.onclick = function(){
    lunbo(banner_lis)
    return false;
  }

};


